#include "Circle.h"
/**
 * 八分法画圆，每次画八个点
 * center 为圆心
 * */
void CirclePoint(GLint x, GLint y, Point center)
{
    putPixel(x + center.x, y + center.y);
    putPixel(-x + center.x, y + center.y);
    putPixel(x + center.x, -y + center.y);
    putPixel(-x + center.x, -y + center.y);
    putPixel(y + center.x, x + center.y);
    putPixel(-y + center.x, x + center.y);
    putPixel(y + center.x, -x + center.y);
    putPixel(-y + center.x, -x + center.y);
}
/**
 * 圆的扫描转换
 * */
void MidBresenhamCircle(Point center, GLint radius)
{
    GLint x, y, d;
    x = 0, y = radius;
    d = 1 - radius;

    while (x <= y)
    {
        CirclePoint(x, y, center);

        if (d < 0)
        {
            d += 2 * x + 3;
        }
        else
        {
            d += 2 * (x - y) + 5;
            y--;
        }
        x++;
    }
}